<include file="Common/header" />
    <div class="container">
        <div class="row">
                <include file="Common/left_siber" />
            <div class="col-md-10">
                <div class="page-header"><h3>{$page_title}</h3></div>
                        <div class="btn-group  role="group" aria-label="" style="padding-bottom:10px;" >
                        <a  class="btn btn-default  <if condition="ACTION_NAME eq 'index' ">active</if>" href="{:U('Article/index')}">所有文章</a>&nbsp;
                        <a  class="btn btn-default  <if condition="ACTION_NAME eq 'add' ">active</if>" href="{:U('Article/add')}"> 添加文章</a>

            </div>
                <div>
                    <table class="table table-bordered ">
                        <thead>
                            <tr class="active">
                                <td>id</td>
                                <td> 文章内容</td>
                                <td>所属分类</td>
                                <td> 作者</td>
                                <td> 发布时间</td>
                                <td>状态</td>
                                <td>操作</td>
                            </tr>
                        </thead>
                        <tbody>
                        <foreach name="articles" item="a">
                            <tr>
                                <td>{$a['aid']}</td>
                                 <td>{$a['title']}</td>
                                <td>{$a['cname']}</td>
                                <td>{$a['author']}</td>
                                <td>{$a['add_time']|date="Y-m-d H:i", ###}</td>
                                   <td>
                                       <if condition="$a['status']">
                                           <span class="label label-success">开启</span>
                                           <else/>
                                           <span class="label label-danger">关闭</span>
                                       </if>
                                   </td>
                                   <td width="100">
                                        <a class="btn-default" href="{:U('Article/edit',array('aid'=>$a['aid']))}" title="编辑" style="display: inline"><i class="glyphicon glyphicon-edit"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        <a class="btn-default" href="javascript:delArticle({$a['aid']})" title="删除" style="display: inline"><i class="glyphicon glyphicon-trash"></i></a>
                                  </td>
                            </tr>
                        </foreach>
                        </tbody>
                    </table>
                    <div>
                        <nav aria-label="center"><ul class="pagination">{$Page}</ul></nav>
                </div>
        </div>
        </div>
    </div>
<script>
  function delArticle(aid) {
        layer.confirm(' 确认删除？',{
          btn:['是','否']
      },function () {
            $.ajax({
                'url':"{:U('Article/delete')}",
                'type':'POST',
                'dataType':'json',
                'data':{'aid':aid},
                success:function (phpReturnData) {
                    if(phpReturnData.status==1){
                        layer.msg(phpReturnData.message,{'icon':6},function () {
                            window.location=location;
                        })
                    }else{
                        layer.msg(phpReturnData.message,{'icon':5});
                        }
                    }
                })
            })
        }
</Script>
<include file="Common/footer" />